import Im from './Im'
class Request {
	constructor() {

	}

	request({url, data = {}, method = 'GET'}) {
		return new Promise((resolve, reject) => {
			uni.request({
				url,
				data,
				method,
				success: res => {
					if (res.statusCode === 200) {
						resolve(res.data)
					}else if(res.statusCode == 500){
						uni.showToast({
							title: res.data.error,
							icon: 'none'
						})
						return ;
					} else {
						reject(res)
					}
				},
				fail: err => {
					reject(err)
				}
			})
		})
	}
}

export default Request;